package com.example.teaching_server.repository;

import com.example.teaching_server.entity.CourseEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 课程数据访问层
 */
@Repository
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {

    /**
     * 按类别查询课程
     */
    List<CourseEntity> findByCategory(String category);

    /**
     * 按课程名称排序查询所有课程
     */
    List<CourseEntity> findAllByOrderByCourseNameAsc();

    /**
     * 按类别和课程名称排序查询课程
     */
    List<CourseEntity> findByCategoryOrderByCourseNameAsc(String category);

    /**
     * 按课程名称精确查询
     */
    Optional<CourseEntity> findByCourseName(String courseName);
}
